package com.lx.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lx.dao.UserMapper;
import com.lx.entities.User;
import com.lx.entities.UserExample;
import com.lx.service.UserService;

@Service
public class UserServiceImpl implements UserService{

	@Autowired
	private UserMapper umapper;
	
	@Override
	public List<User> findUsers() {
		return umapper.selectByExample(new UserExample());
	}

	@Override
	public int save(User u) {
		int res = 0;
		if(u.getId() == null)
			res =umapper.insert(u);
		else
			res = umapper.updateByPrimaryKeySelective(u);
		return res;
	}

	@Override
	public int delUsers(String ids) {
		// TODO Auto-generated method stub
		return umapper.delUsers(ids);
	}

	@Override
	public User findUserById(Integer uid) {
		// TODO Auto-generated method stub
		return umapper.selectByPrimaryKey(uid);
	}

}
